package com.mes.device.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.JoinColumnOrFormula;
import org.hibernate.annotations.JoinColumnsOrFormulas;
import org.hibernate.annotations.JoinFormula;
import org.springframework.context.annotation.Lazy;

import com.mes.basicdata.domain.Dept;
import com.mes.basicdata.domain.Employee;
import com.mes.basicdata.domain.TypesData;
import com.mes.common.domain.BasicModel;
import com.mes.basicdata.domain.Device;
/**
 * 
 * @author LCS
 * data 2017-03-23
 *
 */
@Entity()
@Table(name = "T_MAINTAIN_TASK")
public class MaintainTask extends BasicModel {
	
	public final static int MAINTAINTASK_TASKSTATE_DRAG =0; // �ݸ�
	public final static int MAINTAINTASK_TASKSTATE_DISPATCHED =1; // ���ɹ�
	public final static int MAINTAINTASK_TASKSTATE_STARTED = 2; // �ѿ�ʼ
	public final static int MAINTAINTASK_TASKSTATE_COMPLETED = 3; // �����
	public final static int MAINTAINTASK_TASKSTATE_CANCELED = 4; // ��ȡ��
	
	@Id
	@GenericGenerator(name = "maintainTaskUid", strategy = "assigned")
	@Column(name="TASKUID")
	private String maintainTaskUid;
	
	@Column(name="TASK_NAME")
	private String taskName;
	
	@Column(name="TASK_DESCRIPTION")
	private String taskDescription;
	
	@Column(name="DEVICEUID")
	private String deviceUid;
	
	//many-to-many
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="DEVICEUID",insertable=false,updatable=false)
	private Device device;
	
	@Column(name="DEPTID")
	private String deptUid;
	
	//many-to-many
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="DEPTID",insertable=false,updatable=false)
	private Dept dept;
	
	@Column(name="DISPATCHER")
	private String dispatcherUid;
	
	//many-to-many
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="DISPATCHER",insertable=false,updatable=false)
	private Employee dispatcher;	
	
	@Column(name="EMPLOYEEID")
	private String employeeUid;
	
	//many-to-many
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="EMPLOYEEID",insertable=false,updatable=false)
	private Employee employee;
	
	@Column(name="TASK_TYPE")
	private String taskType;
	
	//many-to-many
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumnsOrFormulas(value={
			@JoinColumnOrFormula(column=@JoinColumn(name="TASK_TYPE",referencedColumnName="ID",nullable=true,insertable=false,updatable=false)),
			@JoinColumnOrFormula(formula=@JoinFormula(value="'maintaintasktype'", referencedColumnName="TYPESNAME"))
	})
	private TypesData taskTypeDesc;
	
	@Column(name="TASK_STATE")
	private Integer taskState;
	
	//many-to-many
	@ForeignKey(name="null")
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumnsOrFormulas(value={
			@JoinColumnOrFormula(column=@JoinColumn(name="TASK_STATE",referencedColumnName="ID",nullable=true,insertable=false,updatable=false)),
			@JoinColumnOrFormula(formula=@JoinFormula(value="'maintaintaskstate'", referencedColumnName="TYPESNAME"))
	})
	private TypesData taskStateDesc;
	
	@Column(name="PLANSTART")
	private Date planStart;
	
	@Column(name="PLANFINISH")
	private Date planFinish;
	
	@Column(name="ACTUALSTART")
	private Date actualStart;
	
	@Column(name="ACTUALFINISH")
	private Date actualFinish;
	
	@Column(name="RELATION_TASKUID")
	private String relationTaskUid;
		
	@Column(name="DISPATCHTIME")
	private Date dispatchTime;
	
	@Transient
	protected String problemType;
	
	public String getProblemType() {
		return problemType;
	}
	public void setProblemType(String problemType) {
		this.problemType = problemType;
	}
	public String getUuid() {
		return this.maintainTaskUid;
	}
	public void setUuid(String uuid) {
		this.maintainTaskUid = uuid;
	}
	
	public String getMaintainTaskUid() {
		return maintainTaskUid;
	}
	public void setMaintainTaskUid(String maintainTaskUid) {
		this.maintainTaskUid = maintainTaskUid;
	}
	public String getTaskName() {
		return taskName;
	}
	public void setTaskName(String taskName) {
		this.taskName = taskName;
	}
	public String getTaskType() {
		return taskType;
	}
	public void setTaskType(String taskType) {
		this.taskType = taskType;
	}

	public Integer getTaskState() {
		return taskState;
	}
	public void setTaskState(Integer taskState) {
		this.taskState = taskState;
	}
	public String getTaskDescription() {
		return taskDescription;
	}
	public void setTaskDescription(String taskDescription) {
		this.taskDescription = taskDescription;
	}
	public String getDeptUid() {
		return deptUid;
	}
	public void setDeptUid(String deptUid) {
		this.deptUid = deptUid;
	}
	public Dept getDept() {
		return dept;
	}
	public void setDept(Dept dept) {
		this.dept = dept;
	}
	public String getDispatcherUid() {
		return dispatcherUid;
	}
	public void setDispatcherUid(String dispatcherUid) {
		this.dispatcherUid = dispatcherUid;
	}
	public Employee getDispatcher() {
		return dispatcher;
	}
	public void setDispatcher(Employee dispatcher) {
		this.dispatcher = dispatcher;
	}
	public String getEmployeeUid() {
		return employeeUid;
	}
	public void setEmployeeUid(String employeeUid) {
		this.employeeUid = employeeUid;
	}
	public Date getPlanStart() {
		return planStart;
	}
	public void setPlanStart(Date planStart) {
		this.planStart = planStart;
	}
	public Date getPlanFinish() {
		return planFinish;
	}
	public void setPlanFinish(Date planFinish) {
		this.planFinish = planFinish;
	}
	public Date getActualStart() {
		return actualStart;
	}
	public void setActualStart(Date actualStart) {
		this.actualStart = actualStart;
	}
	public Date getActualFinish() {
		return actualFinish;
	}
	public void setActualFinish(Date actualFinish) {
		this.actualFinish = actualFinish;
	}
	public String getRelationTaskUid() {
		return relationTaskUid;
	}
	public void setRelationTaskUid(String relationTaskUid) {
		this.relationTaskUid = relationTaskUid;
	}
	public Date getDispatchTime() {
		return dispatchTime;
	}
	public void setDispatchTime(Date dispatchTime) {
		this.dispatchTime = dispatchTime;
	}
	public String getDeviceUid() {
		return deviceUid;
	}
	public void setDeviceUid(String deviceUid) {
		this.deviceUid = deviceUid;
	}
	public Device getDevice() {
		return device;
	}
	public void setDevice(Device device) {
		this.device = device;
	}
	public Employee getEmployee() {
		return employee;
	}
	public void setEmployee(Employee employee) {
		this.employee = employee;
	}
	public TypesData getTaskTypeDesc() {
		return taskTypeDesc;
	}
	public void setTaskTypeDesc(TypesData taskTypeDesc) {
		this.taskTypeDesc = taskTypeDesc;
	}
	public TypesData getTaskStateDesc() {
		return taskStateDesc;
	}
	public void setTaskStateDesc(TypesData taskStateDesc) {
		this.taskStateDesc = taskStateDesc;
	}
	}